# bs4解析

import requests
from bs4 import BeautifulSoup

# bs4 主要用于方便解析html文本

# url = "http://www.xinfadi.com.cn/getPriceData.html"
#
# res = requests.post(url)
# print(res.json())

url = 'https://movie.douban.com/top250'

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
}

res = requests.get(url, headers=headers)
# print(res.text)
page = BeautifulSoup(res.text, 'html.parser')
div = page.find_all("div", class_="item")
# span = div[0].find_all("span", class_="title")
# print(span)
span = {}
for item in range(len(div)):
    span[item] = div[item].find_all("span", class_="title")
for index in range(len(span)):
    print(span[index][0].text)
res.close()
